<%--                                                                       --%>
<%-- Copyright (c) 2005 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<% String ctxPath = request.getContextPath(); %>
<c:set var="editImg">
<img src="<%= ctxPath %>/ep/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.edit" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.edit" bundle="ep.messages"/>">
</c:set>
<c:set var="deleteImg">
<img src="<%= ctxPath %>/ep/images/action/icon_delete.gif" width="15" height="15" border="0" class="actionIcon" alt="<bean-el:message key="image.alt.delete" bundle="ep.messages"/>" title="<bean-el:message key="image.alt.delete" bundle="ep.messages"/>">
</c:set>

<script language="JavaScript">

<%@ include file="/mc/common/jsutils.jsp" %>

  //
function closeWindow() {
  self.close();
}

function doChannelDeleteAction(id){

	if(confirm('<bean-el:message key="ep.channels.confirm.delete" bundle="ep.messages"/>')){
		document.epChannelProgramWithQualifierReportForm.channelId.value = id;
		
	  var qualifierFlag = <c:out value="${epChannelListReportView.map.qualifierFlag}"/>;
	  if(qualifierFlag == true){
		  document.epChannelProgramWithQualifierReportForm.listSessionAttribute.value = 'ChannelQualifierReportResultList';
	  }
	  else{
			document.epChannelProgramWithQualifierReportForm.goBackAction.value = '/ep/channelWithNoQualifierReportList.do';
		  document.epChannelProgramWithQualifierReportForm.listSessionAttribute.value = 'ChannelReportResultList';
	  }
	  document.epChannelProgramWithQualifierReportForm.action = '<c:url value="/ep/channelReportDelete.do"/>';	
    document.epChannelProgramWithQualifierReportForm.submit();
	return;
	}
	return false;
}


function doChannelDeleteAllAction() {
	if(confirm('<bean-el:message key="ep.channels.confirm.delete" bundle="ep.messages"/>')){
    document.epChannelProgramWithQualifierReportForm.channelId.value = 0;
		
	  var qualifierFlag = <c:out value="${epChannelListReportView.map.qualifierFlag}"/>;
	  if(qualifierFlag == true){
		  document.epChannelProgramWithQualifierReportForm.listSessionAttribute.value = 'ChannelQualifierReportResultList';
	  }
	  else{
			document.epChannelProgramWithQualifierReportForm.goBackAction.value = '/ep/channelWithNoQualifierReportList.do';
		  document.epChannelProgramWithQualifierReportForm.listSessionAttribute.value = 'ChannelReportResultList';
	  }
    	document.epChannelProgramWithQualifierReportForm.action = '<c:url value="/ep/channelReportDelete.do"/>';
   	  document.epChannelProgramWithQualifierReportForm.submit();
			return;
	}
	else return false;
}
  
</script>
	  
<html-el:form action="/ep/channelWithQualifierReportList.do">
<input type="hidden" name="listSessionAttribute"/>
<input type="hidden" name="channelId"/>
<input type="hidden" name="goBackAction"/>
<input type="hidden" name="qualifierName" value='<c:out value="${qualifierName}"/>'/>
<input type="hidden" name="selectedQualifierValueName" value='<c:out value="${selectedQualifierValueName}"/>'/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">   
      <div class="generalWrapRight">
        <html-el:button property="closeWinBtn" styleClass="inputButton" onclick="javascript:closeWindow()">
          <bean-el:message key="button.close"  bundle="ep.messages"/>
        </html-el:button>
      </div> 
      <div class="errorMessage"><html-el:errors bundle="ep.messages"/></div>
      
      <c:choose>
        <c:when test="${epChannelListReportView.map.qualifierFlag == true}">
          <div class="pageTitle">
            <bean-el:message key="ep.report.title" bundle="ep.messages"/>: <bean-el:message key="ep.report.list.channel.program.qualifier" bundle="ep.messages"/>
          </div>         
          <div class="pageSubtitle">
            <span class="left"><bean-el:message key="ep.report.search.criteria" bundle="ep.messages"/></span>
          </div>
          
          <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
            <tr>
              <td class="label" width="20%">
                <bean-el:message key="ep.report.label.selectQualifier" bundle="ep.messages"/>:
              </td>
              <td class="labelField" width="80%" nowrap>
                <c:out value="${qualifierName}"/>
              </td>
            </tr>	
            
            <tr>
              <td class="label" width="20%">
                <bean-el:message key="ep.report.label.qualifierValue" bundle="ep.messages"/>:
              </td>
              <td class="labelField" width="80%" nowrap>
                <c:out value="${selectedQualifierValueName}"/>
              </td>
            </tr>
            <tr>
              <td class="label" width="20%">
                <bean-el:message key="ep.report.label.scope" bundle="ep.messages"/>:
              </td>                                             
              <td class="labelField" width="80%" nowrap>
                <bean-el:message key="ep.report.label.scope.channel" bundle="ep.messages"/>
              </td>
            </tr>	
          </table>
        </c:when>
        <c:otherwise>
          <div class="pageTitle">
            <bean-el:message key="ep.report.title" bundle="ep.messages"/>: <bean-el:message key="ep.report.list.channel.no.qualifier" bundle="ep.messages"/>
          </div>
          <div class="pageSubtitle">
            <span class="left"><bean-el:message key="ep.report.label.scope.channel" bundle="ep.messages"/></span>
          </div>
        </c:otherwise>
      </c:choose>
      
      <c:if test="${not empty epChannelListReportView.map.channels}">
        <div class="globalButtonWrap">
          <input type="button" name="selectAllChannels" class="globalButton" value="<bean-el:message key="button.selectAll" bundle="ep.messages"/>"
            onclick="check(this.form.channelIds, this);">
          <input type="button" class="globalButton" value="<bean-el:message key="button.delete" bundle="ep.messages"/>"
            onclick="if (isAnyChecked(this.form.channelIds, '<bean-el:message key="ep.channel.atLeastOne" bundle="ep.messages"/>', '')) doChannelDeleteAllAction();">
        </div>          
      </c:if>
  
      <table class="dataTable" border="0" cellspacing="1" cellpadding="2" summary="Search result table" width="100%">
        <tr class="listHeader">
            <th id="Checkboxes">&nbsp;</th>
            <th id="Name" align="left"><bean-el:message key="ep.report.channel.list.header.name" bundle="ep.messages"/></th>
            <th id="Status" align="left"><bean-el:message key="ep.report.channel.list.header.status" bundle="ep.messages"/></th>
            <th id="Actions" align="left" nowrap><bean-el:message key="ep.report.channel.list.header.action" bundle="ep.messages"/></th>
        </tr>
      
        <!-- results -->
        <c:choose>
          <c:when test="${not empty epChannelListReportView.map.channels}">
            <c:forEach var="item" items="${epChannelListReportView.map.channels}" varStatus="index">	
              <c:choose>
                <c:when test="${index.count %2 == 0}">
                  <tr class="listEven">
                </c:when>
                <c:otherwise>
                  <tr class="listOdd">
                  </c:otherwise>
                </c:choose>
            
                <td headers="Checkboxes" align="center">
                  <input type="checkbox" name="channelIds"
                    onclick="update(this.form.channelIds, this.form.selectAllChannels);"
                    value="<c:out value='${item.map.channelId}'/>" /> 
                </td>
                
                <c:url var="viewUrl" value="/ep/channelView.do">
                  <c:param name="channelId" value="${item.map.channelId}"/>
                </c:url>                
                <td headers="Name">
                  <a href='<c:out value="${viewUrl}"/>' target='window<%=request.getSession().getId()%>'>
                    <c:out value="${item.map.name}"/>
                  </a>
                </td>
              
                <td headers="Status">
                  <c:choose>
                    <c:when test="${item.map.status == 0}">
                      <bean-el:message key="ep.label.offline" bundle="ep.messages"/>
                    </c:when>
                    <c:otherwise>
                      <bean-el:message key="ep.label.online" bundle="ep.messages"/>
                    </c:otherwise>
                  </c:choose>
                </td>
    
                <c:url var="editUrl" value="/ep/channelEdit.do">
                  <c:param name="channelId" value="${item.map.channelId}"/>
                </c:url>               
                <td headers="Actions">
                  <c:if test="${epChannelListReportView.map.qualifierFlag == true}">
                      <a href='<c:out value="${editUrl}"/>' target='window<%=request.getSession().getId()%>'>
                      <c:out value='${editImg}' escapeXml="false"/></a>
                  </c:if>
                    <a href='#' onclick="doChannelDeleteAction('<c:out value="${item.map.channelId}"/>');">
                      <c:out value='${deleteImg}' escapeXml="false"/></a>
                </td>
              </tr>
            </c:forEach>
          </c:when>
          <c:otherwise>
            <tr class="listOdd">
              <td align="center" colspan="6">
                <bean-el:message key="ep.report.channel.noFound" bundle="ep.messages"/>
              </td>
            </tr>
          </c:otherwise>
        </c:choose>		
      </table>
		
      <!-- pagination -->
      <c:if test="${not empty epChannelListReportView.map.channels}">
          <%@ include file="/mc/common/pager.jsp" %>
      </c:if>

    </td>
	</tr>
</table>
</html-el:form>
